import { Link } from "react-router-dom"

import { useDataMapping, useDigital, useLocale } from "@/hooks"
import { formatTime } from "@/utils/util"

export interface RootObject {
	id: string
	orderNo: string
	gameType: number
	gameTypeDesc: string
	tableId: number
	tableCode: string
	tableName: string
	handCode: string
	clubId: number
	clubName: string
	userId: string
	userName: string
	nickName: string
	merchantId: string
	merchantName: string
	parentProxyId: string
	parentProxyName: string
	parentProxyPath: string
	obDeviceType: number
	orderIp: string
	parentOrderType: number
	orderType: number
	parentOrderTypeDesc: string
	orderTypeDesc: string
	orderAmount: number
	orderStatus: number
	preferentialAmount: number
	payAmount: number
	serviceContribution: number
	netTime: string
	orderTime: string
	createdAt: string
	updatedAt: string
	serialNo: string
}

const orderListColumns = () => {
	const { renderFormat } = useDigital()
	const { newFormat } = useLocale()
	const { getFromDic } = useDataMapping()
	const orderList_id = {
		title: "title.orderNo",
		width: 200
	}
	const orderList_orderNo = {
		title: "label.threePartyOrderNumber",
		width: 200
	}
	const orderList_userName = {
		title: "label.playerName",
		width: 120
	}
	const orderList_clubId = {
		title: "label.clubId",
		width: 120,
		render: (clubId: string) => <Link to={`/dxn/clubManager/clubList?clubId=${clubId}`}>{clubId}</Link>
	}
	const orderList_tableName = {
		dataIndex: "tableName",
		title: "label.tableName",
		width: 120
	}
	const orderList_gameTypeDesc = {
		dataIndex: "id",
		title: "label.gameName",
		width: 120
	}
	const orderList_parentOrderTypeDesc = {
		title: "label.orderType",
		width: 120
	}
	const orderList_orderTypeDesc = {
		title: "label.orderSubclass",
		width: 120
	}
	const orderList_orderAmount = {
		title: "label.orderAmount",
		width: 120,
		render: renderFormat
	}
	const orderList_preferentialAmount = {
		title: "label.discountedPrice",
		width: 120,
		render: renderFormat
	}
	const orderList_payAmount = {
		title: "label.theAmountActuallyPaid",
		width: 120,
		render: renderFormat
	}
	const orderList_serviceContribution = {
		title: "label.dxnPumpContribution",
		width: 160,
		render: renderFormat
	}
	const orderList_orderIp = {
		title: "label.orderIp",
		width: 120
	}
	const orderList_orderTime = {
		title: "label.orderTime",
		width: 200,
		render: (v: string) => formatTime(v)
	}
	const orderList_obDeviceType = {
		title: "label.orderingTerminal",
		width: 120,
		render: getFromDic("gameDeviceType", false)
	}
	const orderList_orderStatus = {
		title: "funds.proxy_member_funds_record.order_status",
		width: 120,
		render: (v: number) => (v === 1 ? newFormat("label.settled") : newFormat("label.unsettlement"))
	}
	const orderList_netTime = {
		title: "label.netAtString",
		width: 200,
		render: (v: string) => formatTime(v)
	}
	return {
		orderList_id,
		orderList_orderNo,
		orderList_userName,
		orderList_clubId,
		orderList_tableName,
		orderList_gameTypeDesc,
		orderList_parentOrderTypeDesc,
		orderList_orderTypeDesc,
		orderList_orderAmount,
		orderList_preferentialAmount,
		orderList_payAmount,
		orderList_serviceContribution,
		orderList_orderIp,
		orderList_orderTime,
		orderList_obDeviceType,
		orderList_orderStatus,
		orderList_netTime
	}
}
export default orderListColumns
